<template>
  <div class="vote-box">
    <div class="serviceHeader">
      <div class="breadcrumbs">
      </div>
      <div class="container">
        <div class="content">
          <div class="service-box service-main-box">
            <div class="service-content-box">
              <div class="box-hd">
                <h1 class="title">小法庭</h1>
              </div>
              <div>
                <h1 v-if="tribunal_info.status == 0" style="text-align: center;font-size: 30px">双方提交证据阶...</h1>
                <h1 v-else-if="tribunal_info.status == 1" style="text-align: center;font-size: 30px">评审阶段...</h1>
                <h1 v-else-if="tribunal_info.status == 2" style="text-align: center;font-size: 30px">已结案,{{ tribunal_info.user_vote > tribunal_info.store_vote?'买家获胜':'卖家获胜' }}</h1>
                <div class="tribunal-header">
                  <div style="width: 750px;font-size: 20px;display: flex">
                    <p style="align-self: center">案件描述：{{tribunal_info.tribunal_describe}}</p>
                  </div>
                  <div><img style="width: 234px;height: 230px;" src="../../assets/img/法官.webp" alt=""></div>
                </div>
              </div>
              <div style="position: relative">
<!--                <el-button v-if="tribunal_info.status == 1" class="vote-button-left" round-->
<!--                           @click="vote(0)" type="primary">支持</el-button>-->
<!--                <el-button v-if="tribunal_info.status == 1" class="vote-button-right" round-->
<!--                           @click="vote(1)" type="danger">支持</el-button>-->
                <!--                <button class="vote-button" style="position: absolute;left: 0px;">支持1</button>-->
                <!--                <button class="vote-button" style="position: absolute;right: 0px;">支持</button>-->
                <vote
                    :user_vote="tribunal_info.user_vote"
                    :store_vote="tribunal_info.store_vote"
                >
                </vote>
              </div>
              <div class="box-bd">
                <div class="service-step-box">
                  <div class="service-section">
                    <div class="section-hd"><h2 class="section-title">选择进行服务的商品</h2></div>
                    <div class="section-bd">
                      <div class="product-detail">
                        <dl class="detail-list">
                          <dt class="name">{{ order_goods.productName}}</dt>
                          <dd class="imei-no">
                            <span class="goods_price">¥{{ order_goods.totalPrice }}</span>
                            <span style="margin-left: 100px;color: #b0b0b0">x{{ order_goods.quantity }}</span>
                          </dd>
                        </dl>
                        <img
                            :src="order_goods.imgurl"
                            alt="" class="thumb">
                      </div>
                    </div>
                  </div>
                  <div class="service-section">
                    <div class="section-bd">
                      <!-- 陈词-->
                      <div class="et-hero-tabs-container">
                        <router-link class="et-hero-tab" active-class="tabs_active"
                                     :to="{
                          path: '/tribunalDetail/presentation',
                          query: {
                            good_id: this.$route.query.good_id,
                            orderNo: this.$route.query.orderNo,
                            tribunal_id:this.$route.query.tribunal_id
                          }
                                     }">双方陈词</router-link>
                        <router-link class="et-hero-tab" active-class="tabs_active"
                                     :to="{
                          path: '/tribunalDetail/transactionRecords',
                          query: {
                            good_id: this.$route.query.good_id,
                            orderNo: this.$route.query.orderNo,
                            tribunal_id:this.$route.query.tribunal_id
                          }
                                     }">交易记录</router-link>
                      </div>
                      <div>
                        <router-view></router-view>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="breadcrumbs">
        <div class="container">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vote from "../page/Vote";
import axios from "axios";
const connect=axios.create({
  // baseURL:"http://192.168.55.74:8081"
  baseURL:"http://10.22.112.205:8081"
})
export default {
  name: "tribunalDetail",
  components: {Vote},
  data() {
    return {
      tribunal_info: {},
      order_goods: {},
    }
  },
  created() {
    this.getTribunalInfo()
    this.getOrderGoodInfo()
  },
  methods:{
    async vote(vote) {
      const confirmResult = await this.$confirm('是否确认投票, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).catch((err) => err);
      if (confirmResult !== 'confirm') {
        return this.$message.info('已取消');
      }
      //投票
      const res = await connect.get("/tribunal/updateTribunalById",{
        params: {
          vote: vote,
          user_name: sessionStorage.getItem('username'),
          tribunal_id:this.$route.query.tribunal_id
        }
      })
      if (res.data.status == 200){
        this.$message({
          type: 'success',
          message: "投票成功",
        });
        //刷新
        location.reload()
      } else {
        this.$message.error(res.data.msg || '投票失败');
      }
    },
    async getTribunalInfo() {
      let res = await connect.get('/tribunal/getTribunalDetailById', {
        params: {
          tribunal_id:this.$route.query.tribunal_id
        }
      })
      this.tribunal_info = res.data.data
    },
    async getOrderGoodInfo() {
      let res = await connect.get('/orders/getOrderGoodByGoodIdAndOrderNo', {
        params: {
          'good_id': this.$route.query.good_id,
          'orderNo': this.$route.query.orderNo,
        }
      })
      this.order_goods = res.data.data
    },
  }
}
</script>

<style scoped>
.vote-button-left {
  position: absolute;
  left: 0px;
  background-color: #5e51e3;
}
.vote-button-right {
  position: absolute;
  right: 0px;
  /*background-color:#de3460;*/
  background-color:red;
}
/*tabs*/
.et-hero-tabs-container {
  /*border: 1px solid #c5c5c5;*/
  border-bottom: 1px solid #c5c5c5;
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 70px;
  background: #fff;
  z-index: 10;
}
.et-hero-tab {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  color: #000;
  letter-spacing: 0.1rem;
  transition: all 0.5s ease;
  font-size: 16px;
}
.et-hero-tab:hover {
  border-bottom: 4px solid #FF6600;
  /*color: white;*/
  /*background: #FF6600;*/
  transition: all 0.1s ease;
}

.tabs_active {
  border-bottom: 4px solid #FF6600;
}

.et-hero-tab-slider {
  position: absolute;
  bottom: 0;
  width: 0;
  height: 6px;
  background: #66B1F1;
  transition: left 0.3s ease;
}
/*tabs*/
.tribunal-header {
  display: flex;
  flex-direction: row;
}

.goods_price {
  color: red;
  font-weight: bold;
}

.vote-box {
  margin: 0 auto;
}

.serviceHeader {
  background: #f5f5f5;
}

.breadcrumbs, .breadcrumbs a {
  color: #757575;
}

.breadcrumbs {
  height: 40px;
  font-size: 12px;
  line-height: 40px;
  background: #f5f5f5;
}

.container {
  width: 1226px;
  margin-right: auto;
  margin-left: auto;
}

.content {
  width: 100%;
}

.service-main-box {
  padding: 36px 0;
}

.service-box {
  background: #fff;
}

.service-content-box {
  margin: 0 120px;
}

.title {
  margin: 0;
  font-size: 36px;
  font-weight: 400;
  line-height: 68px;
  color: #b0b0b0;
}

.service-content-box .service-section .section-hd {
  height: 50px;
  padding: 0 32px;
  margin-bottom: 28px;
  border-left: 2px solid #ff6700;
  background-color: #eee;
  color: #333;
}

.service-content-box .service-section .section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  line-height: 50px;
}

.service-content-box .service-section .section-bd {
  margin-bottom: 28px;
}

.service-content-box .product-detail {
  position: relative;
  height: 70px;
  padding: 35px 124px 35px 135px;
  border: 1px solid #e0e0e0;
  border-left: 2px solid #b0b0b0;
  font-size: medium;
}

.service-content-box .product-detail .detail-list, .service-content-box .product-detail .detail-list dd {
  margin: 0;
}

.service-content-box .product-detail .back {
  position: absolute;
  right: 40px;
  top: 60px;
  font-size: 12px;
  color: #ff6700;
}

.service-content-box .product-detail .thumb {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 100px;
  height: 100px;
}

.service-content-box .service-section .section-hd {
  height: 50px;
  padding: 0 32px;
  margin-bottom: 28px;
  border-left: 2px solid #ff6700;
  background-color: #eee;
  color: #333;
}

.service-content-box .service-section .section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  line-height: 50px;
}

.service-content-box .service-label-list {
  width: 902px;
  margin: 0;
  padding: 0;
  list-style-type: none;
  overflow: hidden;
  _zoom: 1;
}

ul {
  display: block;
  list-style-type: disc;
  margin-block-start: 1em;
  margin-block-end: 1em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  padding-inline-start: 40px;
}

.service-content-box .service-label-list-large li {
  width: 284px;
  height: 76px;
  margin-right: 15px;
}

.service-content-box .service-label-list .active {
  border-color: #83c44e;
  color: #83c44e;
  cursor: default;
}

.service-content-box .service-label-list li {
  float: left;
  _display: inline;
  width: 160px;
  height: 40px;
  margin: 0 20px 20px 0;
}

/*router-link*/
.service-content-box .service-label-list-large a {
  width: 282px;
  height: 74px;
  font-size: 18px;
  line-height: 74px;
}

.service-content-box .service-section .tip {
  margin: -10px 0 30px 20px;
  color: #757575;
}

/*router-link*/
.service-content-box .service-label-list a {
  display: block;
  width: 158px;
  height: 38px;
  border: 1px solid #b0b0b0;
  font-size: 14px;
  line-height: 38px;
  text-align: center;
  color: #757575;
  cursor: pointer;
}
</style>
